package com.t174.car.controller;

import com.t174.car.dao.CarxiaoliangDao;
import com.t174.car.entity.CarCheliangBean;
import com.t174.car.entity.Carxiaoliang;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/xiaoliang")
@Scope("prototype")
public class CarxiaoliangController {
    @Autowired
    CarxiaoliangDao carxiaoliangDao;
    @RequestMapping("/xiaol")
    @ResponseBody

    public List<Carxiaoliang> queryGroupZhuangXiu(){
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        List<Carxiaoliang> list = carxiaoliangDao.carxiaoliang();
        return list ;
    }
    @RequestMapping("/tongji")
    @ResponseBody
    public Map<String,List<Object>> carxiaol(){
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Map<String,List<Object>> map = new HashMap<>() ;
        List<Carxiaoliang> list = carxiaoliangDao.carxiaomoney();
        List<Object> list1 = new ArrayList<>() ;
        List<Object> list2 = new ArrayList<>() ;

        for(Carxiaoliang bean : list){
            list1.add(bean.getDate()) ;
            list2.add(bean.getCsmoney()) ;
        }

        map.put("xq",list1) ;
        map.put("xqc",list2) ;

        return map ;
    }
//    @RequestMapping("/tongji")
//    @ResponseBody
//    public Map<String,List<Carxiaoliang>> queryGroupType() {
//        try {
//            Thread.sleep(500);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        List<Carxiaoliang> list = carxiaoliangDao.carxiaoliang();
//        Map<String, List<Carxiaoliang>> map = new HashMap<>();
//        map.put("t", list);
//        return map;
//    }
}
